﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;

namespace TEL.ClientClasses
{
    public class Utils
    {
        public static bool IsFreeEndPoint(IPEndPoint endPoint)
        {
            bool res = false;
            try
            {
                List<IPEndPoint> active = new List<IPEndPoint>(); 
                active.AddRange((from ip in IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners() select ip).ToList());
                active.AddRange((from ip in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners() select ip).ToList());
                res = (from q in active where q.Equals(endPoint) select q).Count() == 0;
            }
            catch (Exception)
            {
            }
            return res;
        }
    }
}
